How to Receive Query String Value in JavaScript ?

How to Receive Query String Value in JavaScript ?

function getuserinfo(){
	const queryParams = new URLSearchParams(window.location.search);
	const id = queryParams.get('id');
	alert(id)
}